## Python Script "survey_view"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Redirect to default survey viewer
##
pm = context.portal_membership
from Products.ArchSurvey.Permissions import TAKE_SURVEY, EDIT_CONTENT_PERMISSION, VIEW_RESULTS

if ( pm.checkPermission(TAKE_SURVEY, context) ):
	return state.set(status='take')

if ( pm.checkPermission(EDIT_CONTENT_PERMISSION, context) ):
	return state.set(status='edit')

if ( pm.checkPermission(VIEW_RESULTS, context) ):
	return state.set(status='results')

return state.set(status='nowhere')